//
//  AppClickModifier.swift
//  TimMusic
//
//  Created by nkl on 2024/10/21.
//

import AppIntents
import Foundation
import SwiftUI
import SwiftUICore

struct AppClickModifier: ViewModifier {
    var urlString: String

    func body(content: Content) -> some View {
        if #available(iOS 17.0, *) {
            let intent: MusicClickIntent = MusicClickIntent()
            return AnyView(
                Button(intent: intent) {
                    content
                }
                .buttonStyle(.borderless)
            )
        } else if let url = URL(string: urlString) {
            return AnyView(
                Link(destination: url) {
                    content
                }
            )
        } else {
            return AnyView(
                content
            )
        }
    }
}
